// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type {NextApiRequest, NextApiResponse} from 'next'
const NodeRsa = require('node-rsa');

type Data = {
  publicKey: string,
  privateKey: string
}

export default function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data | {}>
) {
  const key = new NodeRsa({b:1024});
  key.setOptions({encryptionScheme: "pkcs1"});
  const publicKey = key.exportKey('public');
  const privateKey = key.exportKey('private');
  res.status(200).json({ publicKey, privateKey })
}
